﻿using System.Security.AccessControl;

namespace Lesson10_练习题;

class Program
{
    static void Main(string[] args)
    {
        #region   练习1
        //使用LinkedList,加入10个随机整形变量
        
        //正向循环打印
        
        //反向循环打印
        LinkedList<int> list = new LinkedList<int>();
        Random rnd = new Random();
        
        for(int i = 1; i <= 10; i++)
        {
            list.AddLast(rnd.Next(1, 101));   //随机生成的范围为1-100)
        }
        //从头节点开始循环打印
        LinkedListNode<int> node = list.First;
        while (node!=null)
        {
            Console.WriteLine(node.Value);
            node = node.Next;
        }

        Console.WriteLine("****************");
        
        LinkedListNode<int> tail = list.Last;

        while (tail != null)
        {
            Console.WriteLine(tail.Value);
            tail = tail.Previous;

        }
        #endregion
    }
}